﻿using System;

namespace Program14
{
    class Program
    {
        static void Main(string[] args)
        {
            //数组练习1：从一个整数数组中取出最大的整数，最小的整数，总和，平均值
            int[] number = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            int max;//最大
            int min;//最小
            int sum;//总和

            max = min = number[0];
            sum = 0;

            for (var i = 0; i < number.Length; i++) 
            {
                if(number[i]>max)
                {
                    max = number[i];
                }
                if(number[i]<min)
                {
                    min = number[i];
                }
                sum += number[i];
            }
            Console.WriteLine("整个数组的最大值{0},最小值{1},总和是{2},平局值{3}", max, min, sum, sum / number.Length);
        }
    }
}
